from rest_framework import serializers
from .models import UserCoupon, Coupon


class CouponModelSerializer(serializers.ModelSerializer):
    """优惠券的序列化器"""

    class Meta:
        model = Coupon
        fields = ['name', 'sale', 'coupon_type', 'condition']


class UserCouponModelSerializer(serializers.ModelSerializer):
    """用户优惠券序列化器"""
    coupon = CouponModelSerializer()

    class Meta:
        model = UserCoupon
        fields = ['id', 'start_time', 'end_time', 'coupon' ]
